<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<html>
	<head>
		<title>My JSP 'updateStyle.jsp' starting page</title>
		<script type="text/javascript">
		$(function(){
			$("input[type='radio']",$("#styleType"))
				.on("ifChanged", function(event){
					changeType($(this));
				});
		});
		var type="";
		 function changeType(item){
		    type=item.val();
		  }
	function messageShow(temp) {
		$("#message").html(
				"<button data-dismiss=\"alert\" class=\"close\">×</button>"
						+ temp);
		$("#message").show();
		$(function() {
			setTimeout(function() {
				$("#message").hide();
			}, 6000);
		});
	}
	function updateAjaxPackformStyle() {
	var tempString=$("#styleContent").val();
	tempString=encodeURI(tempString);
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/packformStyle/updateAjaxPackformStyle',
			data : 'packformStyleId=${packformStyle.id}&content=' + tempString+ '&styleName=' + $("#styleName").val()+'&type='+type,
			dataType : 'json',
			success : function(data) {
				if (data.status == "1") {
					messageShow("更新成功");
				} else {
					messageShow("更新失败");
				}
			},
			error : function() {
			    alert("error");
				messageShow("更新失败");
			}
		});
	}
	
</script>
	</head>

	<body>
	<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">${titlePage}</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				<div class="form-group row">
		<div id="message" class="alert alert-success" style="display: none;">
			<button data-dismiss="alert" class="close">
				×
			</button>
		</div>
		<fieldset>
		<input type="hidden" value="" id="hiddenString">
		<div class="col-sm-6">
			<div class="input-group col-sm-12">
				<label for="pmsprinters_corpLevel" class="input-group-text">
					随箱单名称:
				</label>
				<div class="col-sm-6">
					<input type="text" id="styleName" name="styleName"
						value="${packformStyle.styleName }" class="form-control input-large required"
						minlength="3" />
				</div>
			</div>
		</div>
		
		<div class="col-sm-6">
			<div class="input-group col-sm-12">
				<label for="pmsprinters_corpLevel" class="input-group-text">
				<!-- 原来的随箱单样式去掉（没用）,暂时把这个字段用于判断是否显示库位 -->
					是否带库位:
				</label>
				<div class="col-sm-6" id="styleType">
					<input class="form-control" type="radio" name="type" value="A4" <c:if test="${packformStyle.type eq 'A4'}">checked</c:if> onchange="changeType(this)">是
					<span style="margin-left: 10px;"> </span>
					<input class="form-control" type="radio" name="type" value="A5" <c:if test="${packformStyle.type eq 'A5'}">checked</c:if> onchange="changeType(this)">否
				</div>
			</div>
		</div>
		
		</fieldset>
		</div>
		
		
		
		</div>
		</div>
		</div>
		</div>
		
		<div class="row">
		<div class="col-md-12">

		<div class="form-horizontal">
			<div class="form-group row">
				<div class="col-sm-12">
		          <textarea class="form-control" rows="20" cols="20"  id="styleContent">${packformStyle.styleContent}</textarea>
		       </div>
	       </div>
	       
	       <div class="modal-footer bg-gray">
				<input id="submit_btn" class="btn btn-primary" type="button"
					value="修改" onclick="updateAjaxPackformStyle()" />
				<input id="cancel_btn" class="btn" type="button" value="返回"
					onclick="history.back()" />
			</div>
		</div>
		</div>
		</div>
		
		</section>
	</body>
</html>
